package com.example.blog.config;

import com.example.blog.entity.Photo;
import com.example.blog.entity.Result;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.List;

public interface SmmsDao {

    void init() throws Exception;

    void destroy();

    Result upload(MultipartFile file);

    default Result upload(MultipartFile[] files){
        // 成功个数
        List<Object> photos = new ArrayList<>();
        if(null != files){
            for (MultipartFile file : files) {
                Result result = upload(file);
                if(result.getCode() == 200){
                    photos.add(result.getData());
                }
            }
        }
        return Result.ok(photos);
    };

    Result delete(String hash);
}
